package com.tian.producer;

import com.alibaba.fastjson.JSON;
import com.tian.enums.ChargeStationRabbitMQConstant;
import com.tian.enums.MessageRetryTypeEnum;
import com.tian.message.StationGunCommunicateLogMessage;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * {@code @description:} 充电桩通信日志消息生产者
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-08-23 11:29
 * {@code @version:} 1.0
 */
@Component
public class StationGunCommunicateLogProducer {
    @Resource
    private BaseProducer baseProducer;

    public void send(StationGunCommunicateLogMessage stationGunCommunicateLogMessage) {
        String content= JSON.toJSONString(stationGunCommunicateLogMessage);
        baseProducer.sendWithRetry(content, MessageRetryTypeEnum.STATION_GUN_COM_LOG_PRODUCER.getCode(),
                stationGunCommunicateLogMessage.getReqId(), ChargeStationRabbitMQConstant.STATION_GUN_COM_LOG_EXCHANGE, ChargeStationRabbitMQConstant.STATION_GUN_COM_LOG_ROUTING_KEY ); // 发送消息
    }
}
